// Copyright (c) 2025 Huawei Technologies Co., Ltd.
// openFuyao is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

package lm

import (
	"reflect"
	"testing"
)

func TestListLabels(t *testing.T) {
	tests := []struct {
		name     string
		labelers list
		want     Labels
	}{
		{
			name: "test list labels",
			labelers: list{
				Labels{"label1": "value1", "label2": "value2"},
				Labels{"label3": "value3", "label4": "value4"},
			},
			want: Labels{"label1": "value1",
				"label2": "value2",
				"label3": "value3",
				"label4": "value4"},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := tt.labelers.Labels(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("Labels() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestMergeSuccess(t *testing.T) {
	type args struct {
		labelers []Labeler
	}
	tests := []struct {
		name string
		args args
		want Labeler
	}{
		{
			name: "test merge",
			args: args{
				labelers: []Labeler{
					Labels{"label1": "value1"},
					Labels{"label2": "value2"},
				},
			},
			want: list{Labels{"label1": "value1"}, Labels{"label2": "value2"}},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := merge(tt.args.labelers...); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("merge() = %v, want %v", got, tt.want)
			}
		})
	}
}
